import React from 'react';
import { connect } from 'react-redux'
import {Select} from 'antd'
import {getprovincefetch} from 'actions/common'
@connect(
    (state, props) => ({
      config: state.config,
      userInfoList: state.userInfoList,
    })
  )
class City extends React.Component {
  constructor(props){
    super(props);
    this.state = {
        province:""
    };
  }
  componentDidMount(){
    
  }
  componentWillMount() {
    this.props.dispatch(getprovincefetch("",(respose) => {
        this.setState({
            province:respose.respData
        })
      }))
  }
  handleChange(value){
    this.props.stateprovince(value)
  }
  render(){
    const Option = Select.Option;
    const province=this.state.province?this.state.province:[];
    return (
            <Select placeholder="请选择" value={this.props.province} onChange={this.handleChange.bind(this)} style={{ width: 180 }}>
                <Option key={99999} value={''}>全部</Option>
                {
                  province.map((item,i)=>{
                      return(
                          <Option key={item.areaId} value={item.areaId}>{item.areaName}</Option>
                      )
                  })
                }
            </Select>
    )
  }
}
export default City;